
/*
 *************************************************************************
 *西瑞克斯研发管理系统
 *版 本: 1.0   
 *日 期：02/08/2012    
 *作 者： 王浩 QQ：873987060   
 *************************************************************************   
 */
package com.application.summary1week.struts.actions;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Map;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.manager.commons.config.ConfigFactory;
import com.manager.commons.page.PageBean;
import com.manager.commons.RandomKey;
import com.manager.commons.CommonUtil;
import com.application.attachment.entity.Attachment;
import com.application.attachment.service.AttachmentService;
import com.application.attachment.struts.form.AttachmentForm;
import com.application.summary1week.entity.Summary1week;
import com.application.summary1week.struts.form.Summary1weekForm;
import com.application.summary1week.service.Summary1weekService;
import com.application.summary1week.commons.Constants;

/**
 * 
 * Description:Summary1weekAction<br />
 * 
 * Version:V0.1<br />
 * 
 * Author: 王浩 QQ：873987060 <br />
 * 
 * History: <br />
 * 
 * 02/08/2012
 * 
 */
public class Summary1weekAction extends DispatchAction {

	/**
	 * Service层实例
	 */
	private Summary1weekService summary1weekService;
	private AttachmentService attachmentService;

	/**
	 * 日志
	 */
	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * 实体对象
	 */
	private Summary1week summary1week;

	/**
	 * 采用partialList方式分页程序
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public ActionForward getSummary1weekPartialList(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("searchSummary1week" + "开始");
		Summary1weekForm summary1week = (Summary1weekForm) form;
		// 统计总记录数的sql语句
		int resultSize = 0;
		// 初始化pageBean供分页所用
		PageBean pageBean = null;
		// 取得当前页list数据
		List summary1weekList = null;
		resultSize = summary1weekService.getAllCountSummary1week(summary1week);
		pageBean = PageBean.getPageBean("summary1weekTab", resultSize, request);
		summary1weekList = summary1weekService.searchSummary1week(summary1week,
				pageBean);
		request.setAttribute("summary1weekList", summary1weekList);
		request.setAttribute("orgSelect", CommonUtil.getOrgSelectNoZB());
		request.setAttribute("yearSelect", CommonUtil.getYearSelect());
		request.setAttribute("moonSelect", CommonUtil.getMoon());
		log.debug("searchSummary1week" + "结束");

		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达新增页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toAddSummary1week(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("toAddSummary1weeks");
		Date date = new Date();
		Summary1weekForm summary1weekForm = new Summary1weekForm();
		summary1weekForm.setId(RandomKey.generateID_Long_19());
		summary1weekForm.setCreatedate(date);
//		request.setAttribute("yearSelect", CommonUtil.getYearSelect());
//		request.setAttribute("moonSelect", CommonUtil.getMoon());
		request.setAttribute("summary1weekForm", summary1weekForm);
		request.setAttribute("kg", CommonUtil.getKz());

		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 增加
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward addSummary1week(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("addSummary1weeks");
		Summary1week summary1week = this.getSummary1week(form);
		summary1week.setCreatedate(new Date());
		this.summary1weekService.insertObject(summary1week);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 删除
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward deleteSummary1week(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("deleteSummary1weeks");
		Summary1weekForm summary1weekForm = (Summary1weekForm) form;
		this.summary1weekService.deleteSummary1weeks(summary1weekForm);
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 到达更新页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward toUpdateSummary1week(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("toUpdateSummary1weeks");
		Summary1weekForm summary1weekForm = (Summary1weekForm) form;
		summary1week = (Summary1week) this.summary1weekService.searchSummary1week(
				summary1weekForm).get(0);
		request.setAttribute(Constants.DEPARTMENT, summary1week);
		request.setAttribute("kg", CommonUtil.getKz());
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 更新
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward updateSummary1week(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		log.debug("updateSummary1weeks");
		Summary1week summary1week = this.getSummary1week(form);
		summary1week.setCreatedate(new Date());
		this.summary1weekService.updateObject(summary1week);
		
		return mapping.findForward(Constants.SUCCESS);
	}

	/**
	 * 查看页面
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward viewSummary1week(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("viewSummary1week");
		Summary1weekForm summary1weekForm = (Summary1weekForm) form;
		summary1week = (Summary1week) this.summary1weekService.searchSummary1week(
				summary1weekForm).get(0);
		request.setAttribute(Constants.DEPARTMENT, summary1week);
		request.setAttribute("kg", CommonUtil.getKz1());
		return mapping.findForward(Constants.SUCCESS);
	}
	
	/**
	 * 打分
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 * @throws Exception
	 */
	public ActionForward dfSummary1week(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		log.debug("viewSummary1week");
		Summary1weekForm summary1weekForm = (Summary1weekForm) form;
		summary1week = (Summary1week) this.summary1weekService.searchSummary1week(
				summary1weekForm).get(0);
		summary1week.setDf(summary1weekForm.getDf());
		summary1week.setBak1(summary1weekForm.getBak1());
		this.summary1weekService.updateObject(summary1week);
		return mapping.findForward(Constants.SUCCESS);
	}
	// get--set
	/**
	 * @return the Summary1weekService
	 */
	public Summary1weekService getSummary1weekService() {
		return this.summary1weekService;
	}

	/**
	 * @param Summary1weekService
	 *            the Summary1weekService to set
	 */
	public void setSummary1weekService(Summary1weekService summary1weekService) {
		this.summary1weekService = summary1weekService;
	}

	/**
	 * 获取Summary1week实体
	 * 
	 * @param ActionForm
	 * @throws InvocationTargetException
	 * @throws IllegalAccessException
	 * @return the Summary1week
	 */
	public Summary1week getSummary1week(ActionForm form)
			throws IllegalAccessException, InvocationTargetException {
		Summary1weekForm summary1weekForm = (Summary1weekForm) form;
		summary1week = new Summary1week();
		BeanUtils.copyProperties(summary1week, summary1weekForm);
		return summary1week;
	}

	public void setSummary1week(Summary1week summary1week) {
		this.summary1week = summary1week;
	}

	/**
	 * @return the attachmentService
	 */
	public AttachmentService getAttachmentService() {
		return attachmentService;
	}

	/**
	 * @param attachmentService the attachmentService to set
	 */
	public void setAttachmentService(AttachmentService attachmentService) {
		this.attachmentService = attachmentService;
	}

	/**
	 * @return the summary1week
	 */
	public Summary1week getSummary1week() {
		return summary1week;
	}


}
